// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path')
function resolve (dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  css: {
    loaderOptions: {
      scss: {
        prependData: '@import "~@/styles/variables.scss";'
      }
    }
  },
  // 配置代理
  devServer: {
    open: true,
    proxy: {
      '/api': {
        // target:`http://10.101.203.184:8080`,//生产环境
        target: 'http://124.42.243.98:18080', // 测试
        // target: `http://192.168.0.110:8080`,
        // target: `http://192.168.2.31:8080`,//李阳帝
        // target: `http://192.168.2.19:3333`,
        changeOrigin: true,
        pathRewrite: {
          '^/api': '/'
        }
      }
    }
  },

  // 配置svg-icon
  chainWebpack (config) {
    config.module
      .rule('svg')
      .exclude.add(resolve('src/assets/images/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/assets/images/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  },

  // 配置开发环境调试
  configureWebpack: config => {
    if (process.env.NODE_ENV !== 'production') { // 开发环境配置
      config.devtool = 'source-map'
    }
  }
}
